import { _decorator, Component, director, game, Label, Node, resources, Sprite, SpriteAtlas } from 'cc';
import { UIManager } from './UIManager';
import Banner from './Banner';
const { ccclass, property } = _decorator;

@ccclass('Health')
export class Health extends Component {
    @property(Node)
    UIManager: Node = null;
    @property(Node)
    Canvas: Node = null;
    start() {
        Banner.Instance.SetCityIsWhite();
        director.addPersistRootNode(this.UIManager);
        this.Canvas.getChildByName("著作权人").getComponent(Label).string = `${Banner.Owner}\n${Banner.License}`;
        resources.load("Common/AgeLimit", SpriteAtlas, (err, event) => {
            if (err) {
                console.log("没有找到适龄图片");
                return;
            }
            this.Canvas.getChildByName("适龄").getComponent(Sprite).spriteFrame = event.getSpriteFrame(Banner.AgeLimit + ``);
        })
    }

}

